Published 4/9/2016 ยท 1 min read
Tags: javascript
Factory Function To Create An Object In JavaScript
Use a constructor function that returns an object. You can then create multiple people passing in the first and last name arguments the createPerson function.
var createPerson = function(firstName, lastName) {
return {
firstName: firstName,
lastName: lastName,
sayHi: function() {
return "Hi there";
}
};
var johnDoe = createPerson("John", "Doe");
var janeDoe = createPerson("Jane", "Doe"); Related Articles
- Compressed NFTs: Collections, Verification, and Building a Claim Page
Taking our cNFT minting system to production: creating verified collections, building a web-based claim flow, and preparing for mainnet deployment.
- Building Compressed NFTs on Solana with Generative SVG Art
A practical guide to creating and minting compressed NFTs (cNFTs) on Solana using Metaplex Bubblegum, with animated SVG artwork generated from wallet addresses.
- Learn Svelte & SvelteKit: Course Overview
A complete beginner's guide to Svelte and SvelteKit. From reactivity basics to full-stack applications, learn the framework that compiles away.