Javascript Function Argument Passing Pass Object to function

Description

Javascript Function Argument Passing Pass Object to function


// Using an object hash to send arbitrary arguments to a function.
function describeBook(args) {
    console.log("Name: " + args.name);
    console.log("Pages: " + args.pages);
    console.log("Chapters: " + args.chapters);
    console.log("Author: " + args.author);
    console.log("Publish Date: " + args.published);
    console.log("Type: " + args.type);
    console.log("Section: " + args.section);
}

describeBook({name:'CSS', 
              pages:1021, //w ww. j a v a 2s .co m
              chapter:22, 
              author: 'java2s.com', 
              published: '2020', 
              type: 'Paperback', 
              section: 'Coding'});



PreviousNext

Related