Chrome and JavaScript

Typing javascript programs into the console of the inspect tools use the combination of shift-enter to type new lines into a program without executing it. This can allow you to test small programs using Google’s browser tools.

A string is an array of characters and not all programming languages support this feature (C for example). An array is a group of similar or different objects types grouped together by an index. The index starts at zero and some languages allow starting the index at 1, but not javascript.

Cool methods in javascript are shift and unshift, which allow you to remove or place an item at the front of the array respectively. Push and pop are used to remove or place items at the end of the array.

You can also use multiple methods on the same variable. For example, you have declared a variable name with a string of “jack”. You want to make the first letter a capital, but leave the rest lower case. You can do that by typing name = name.slice(0).toUpperCase(); and you will get the result of “Jack”. The slice method retrieves the first letter “j” then the toUpperCase method transforms the letter to “J” and then returns “J” to the name variable.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s