//There is a caution! Maybe you did that:
//Let us say an array and a method foo which return first element:
var myArray = ["apple","ball","cat"];
console.log(foo(myArray)); // <- 'apple'
function foo(array){
return array[0];
}
//The above is okay because the functions are uplifted to the top during interpretation time.
//But, this DOES NOT work: (Because the prototype is not definned)
//console.log(myArray.foo())
// <- 'TypeError : foo is not defined yet '
Array.prototype.foo = function(){
return this[0];
}
console.log(myArray.foo())
// 'apple'
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.