Type coercion. When you mix different data types and JS converts data types into one data type ‘on the fly’, when it needs to.

You can declare variables without assigning values to the variables. This makes them print out ‘undeclared’.

Change the value of a variable with variable mutation. You can even change the data type.

var age = 26;
age = 'thirty six';

Prompt function. You can set the value of a variable as the answer to a prompt.

var lastName = prompt('What is the last name?');
console.log(lastName);

Alert function. A window pops up with text you have defined and the option ‘OK’.

alert(name + ' is a ' + age  + ' year old ' + job + '. Is he married? ' + isMarried + '.');

Here is what I did in this lecture. I found it pretty easy compared to Java, with easier syntax and few data types. I also like how it has an immediate impact on a webpage you can view. The prompt and alert functions are probably the biggest takeaways in this lecture, for me. Type coercion and mutation already seem familiar from Java although this is the first time I’ve heard them referred to as such.

Screen Shot 2018-04-02 at 2.34.37 pm.png

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

w

Connecting to %s