Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

function as object

// Function declaration.
function showFavoriteIceCream() {
  const favIceCream = 'chocolate';

  console.log(`My favorite ice cream is ${favIceCream}`);
}

// Let's assign a property.
showFavoriteIceCream.flavours = ['chocolate', 'vanilla', 'strawberry'];

// Let's log the showFavoriteIceCream function.
console.log(showFavoriteIceCream);

// Log
// { [Function: showFavoriteIceCream]
// flavours: [ 'chocolate', 'vanilla', 'strawberry' ] } -> property assigned
Comment

PREVIOUS NEXT
Code Example
Javascript :: create an express application 
Javascript :: javascript function hoisting 
Javascript :: Anonymous Functions with arguments in JavaScript 
Javascript :: jquery find element 
Javascript :: javascript constants 
Javascript :: js string to num 
Javascript :: how to use the foreach fnction javascript loop through array 
Javascript :: firebase get subcollection 
Javascript :: javascript if function multiple conditions 
Javascript :: mdn .map 
Javascript :: unshift javascript 
Javascript :: JavaScript timer set Interval js ClearInterval 
Javascript :: npx vs npm 
Javascript :: create chart in excel using javascript 
Javascript :: react native setTimeOut error 
Javascript :: native stack vs stack 
Javascript :: Format javascript date with date.js library 
Javascript :: .classList 
Javascript :: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 
Javascript :: update 1 element of array javascript 
Javascript :: how to add external link in angular 
Javascript :: private router react v6 
Javascript :: ?. js 
Javascript :: javascript json 
Javascript :: remove row from array javascript 
Javascript :: javascript object prototype 
Javascript :: javascript hashtable 
Javascript :: instantiate js 
Javascript :: end of file expected json 
Javascript :: Event Delegation Example In JavaScript 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =