The code creates an instance of an object and adds two properties and one method to it.
Note that methods are just functions attached to objects.
Then we will have to write the createID function, which creates an ID for the customer.
JavaScript knows which person you’re talking about by using this .
So, now you can use the method user.createID .
The example creates an object by using a template.
You may also use the Object type to create an object.
|
|
new
operator creates an instance of a user-defined object type or of one of the built-in object types that has a constructor function.
random
of the object Math
returns a pseudo-random number between 0 and 1.
String
converts the specified object to a string.
It is a top-level function and is not associated with any object.
A guy catches his wife in bed with his best friend, and he goes, “Sal, I have to! But you?” — Wayne Federman |