Tag javascript map

JavaScript String Search

JavaScript String indexOf() The indexOf() method returns the index (position) of the first occurrence of a string in a string, or it returns -1 if the string is not found: Example let text = “Please locate where ‘locate’ occurs!”; let…

JavaScript String Reference

JavaScript Strings A JavaScript string stores a series of characters like “John Doe”. A string can be any text inside double or single quotes: let carName1 = “Volvo XC60”; let carName2 = ‘Volvo XC60’; String indexes are zero-based: The first…

JavaScript Strings

Strings are for storing text Strings are written with quotes Using Quotes A JavaScript string is zero or more characters written inside quotes. Example let text = “John Doe”;

JavaScript Events

HTML events are “things” that happen to HTML elements. When JavaScript is used in HTML pages, JavaScript can “react” on these events. HTML Events An HTML event can be something the browser does, or something a user does. Here are…

JavaScript Object Constructors

Object Constructor Functions Sometimes we need to create many objects of the same type. To create an object type we use an object constructor function. It is considered good practice to name constructor functions with an upper-case first letter. Object…

JavaScript Display Objects

How to Display JavaScript Objects? Displaying a JavaScript object will output [object Object]. Example // Create an Object const person = {   name: “John”,   age: 30,   city: “New York” }; document.getElementById(“demo”).innerHTML = person;

JavaScript Object Methods

JavaScript Object Methods Object methods are actions that can be performed on objects. A method is a function definition stored as a property value. Property Value firstName John lastName Doe age 50 eyeColor blue fullName function() {return this.firstName + ”…

JavaScript Object Properties

An Object is an Unordered Collection of Properties Properties are the most important part of JavaScript objects. Properties can be changed, added, deleted, and some are read only. Accessing JavaScript Properties The syntax for accessing the property of an object…