Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Adding a Method to a JavaScript Object

// creating an object
let student = { };

// adding a property
student.name = 'John';

// adding a method
student.greet = function() {
    console.log('hello');
}

// accessing a method
student.greet(); // hello
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript countdown 
Javascript :: html js how to draw on screen 
Javascript :: readfilesync buffer 
Javascript :: javascript get character from string 
Javascript :: how to create a website with javascript 
Javascript :: next js styled components classname did not match 
Javascript :: expres body parser 
Javascript :: all redux packages 
Javascript :: how to find last occurrence comma in a string and replace with value in javascript 
Javascript :: ssg full form in nextjs 
Javascript :: active-class router-link 
Javascript :: javascript var,let,const compare 
Javascript :: clear form inside modal after close reactjs 
Javascript :: jspdf 
Javascript :: replace character inside a string in JavaScript 
Javascript :: how to exit node 
Javascript :: extract from a string in javascript 
Javascript :: redux mapstatetoprops get props 
Javascript :: learn mongodb 
Javascript :: how to make a check if 50% of letters are capital in discord js 
Javascript :: check if an array contains a number in javascript 
Javascript :: push object to json array 
Javascript :: export app react native 
Javascript :: regex scan youtube video id 
Javascript :: moment clone 
Javascript :: which object key has highest value javascript 
Javascript :: rect to rect collision 
Javascript :: jest expect string to contain substring 
Javascript :: new line with javascript write 
Javascript :: javascript await return value 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =