为什么jsfiddle给我错误"SyntaxError:Unexpected token:"?

Ste*_*ven 4 javascript jsfiddle

我正在使用结构化的JavaScript代码,它在我的计算机上工作正常.但是当我将它添加到jsFiddle时,它会给我以下错误:

SyntaxError: Unexpected token :
Run Code Online (Sandbox Code Playgroud)

我的代码看起来像这样:

var StentGallery = {
    gallery: null,

    init : function(){
            this.gallery = jQuery('#gallery-list-ui');
            this.resizeImage();
        }
    }
    (...)
}
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么这不适用于jsFiddle?
看看我的小提琴:https://jsfiddle.net/smyhbckx/

Nic*_*ber 5

您的代码中存在语法错误:

var StentGallery = {
    gallery: null,

    init : function(){
           this.gallery = jQuery('#gallery-list-ui');
           this.resizeImage();
           } // <----- this is prematurely closing your object
    }, 

    resizeImage: function(){
    ...
Run Code Online (Sandbox Code Playgroud)

要解决此问题,只需删除该括号:

var StentGallery = {
    gallery: null,

    init : function(){
           this.gallery = jQuery('#gallery-list-ui');
           this.resizeImage();
    },

    resizeImage: function(){
    ...
Run Code Online (Sandbox Code Playgroud)