javascript - jQuery plugin tutorial explanation -


i'm following jquery plugins/authoring tutorial, , couldn't figure out arguments on lines 16 , 18 mean. missing fundamental?

(function( $ ){  var methods = {     init : function( options ) {      // ...      },     show : function( ) {     // ... };  $.fn.tooltip = function( method ) {      // method calling logic     if ( methods[method] ) {         return methods[ method ].             apply( this, array.prototype.slice.call( arguments, 1 ));     } else if ( typeof method === 'object' || ! method ) {         return methods.init.apply( this, arguments );     } else {         $.error( 'method ' +  method + ' not exist on jquery.tooltip' );     }      };  })( jquery ); 

thank you.

arguments array-like object contains parameters passed function, including parameters didn't supply variable name for.

it array-like, not array. not contain of array methods, such slice, why have use array.prototype.slice.call(arguments,...) or [].slice.call(arguments,...) rather using arguments.slice(...)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -