29.07.2016 Views

front-end-developer_1_

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Front-End-Developer - Level 1<br />

Try the confirm() function yourself, now.<br />

You should have seen that confirm() returns one of two values: true or false . Notice<br />

that there are no quotes around these values. true and false aren't strings - they're<br />

called booleans. They simply represent being true or false.<br />

And on that note, you might have noticed that alert() returned undefined , also without<br />

quotes. undefined simply represents that nothing has been returned from the function, or<br />

that a variable hasn't been assigned a value.<br />

Having now used numbers, strings, booleans, and undefined , you've come across four of<br />

the five basic JavaScript data types, or primitives. The last one is null , which represents<br />

nothingness. Don't worry about null for now - we'll learn more about it down the road.<br />

Summary<br />

A function is something that performs an action.<br />

A boolean is true or false .<br />

alert() opens a dialog box and returns undefined .<br />

confirm() opens a dialog box and returns a boolean.<br />

prompt() opens a dialog box and returns a string. The five JavaScript primitives are<br />

numbers, strings, booleans, undefined , and null .<br />

Everything after // is a comment and ignored by JavaScript.<br />

Functions<br />

113

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!