Home

JavaScript For Kids For Dummies Cheat Sheet

|
|  Updated:  
2022-02-25 13:36:43
|   From The Book:  
JavaScript Essentials For Dummies
Explore Book
Buy On Amazon
When you’re programming in JavaScript, you need to know how to convert CSS property names to JavaScript. An important part of JavaScript’s ability to perform useful functions in the browser is its ability to respond to events, including those listed here. Finally, some words cannot be used as JavaScript variables, functions, methods, loop labels, or object names; those reserved words are listed here.

Converting CSS property names to JavaScript

You can convert CSS property names to JavaScript. However, there are a few things you should remember if you plan on doing this. When changing styles with JavaScript, there are a couple simple rules:

  • If the CSS property is one word (such as height), it remains as it is.

  • If the CSS property is more than one word, separated by dashes, it gets converted to camelCase.

Here is a complete reference of the property name conversions from CSS to JavaScript.

CSS Property JavaScript Reference
background background
background-attachment backgroundAttachment
background-color backgroundColor
background-image backgroundImage
background-position backgroundPosition
background-repeat backgroundRepeat
border border
border-bottom borderBottom
border-bottom-color borderBottomColor
border-bottom-style borderBottomStyle
border-bottom-width borderBottomWidth
border-color borderColor
border-left borderLeft
border-left-color borderLeftColor
border-left-style borderLeftStyle
border-left-width borderLeftWidth
border-right borderRight
border-right-color borderRightColor
border-right-style borderRightStyle
border-right-width borderRightWidth
border-style borderStyle
border-top borderTop
border-top-color borderTopColor
border-top-style borderTopStyle
border-top-width borderTopWidth
border-width borderWidth
clear clear
clip clip
color color
cursor cursor
display display
filter filter
float cssFloat
font font
font-family fontFamily
font-size fontSize
font-variant fontVariant
font-weight fontWeight
height height
left left
letter-spacing letterSpacing
line-height lineHeight
list-style listStyle
list-style-image listStyleImage
list-style-position listStylePosition
list-style-type listStyleType
margin margin
margin-bottom marginBottom
margin-left marginLeft
margin-right marginRight
margin-top marginTop
overflow overflow
padding padding
padding-bottom paddingBottom
padding-left paddingLeft
padding-right paddingRight
padding-top paddingTop
page-break-after pageBreakAfter
page-break-before pageBreakBefore
position position
text-align textAlign
text-decoration textDecoration
text-decoration: blink textDecorationBlink
text-decoration: line-through textDecorationLineThrough
text-decoration: none textDecorationNone
text-decoration: overline textDecorationOverline
text-decoration: underline textDecorationUnderline
text-indent textIndent
text-transform textTransform
top top
vertical-align verticalAlign
visibility visibility
width width
z-index zIndex

Web browser events in JavaScript

Web pages are much more than just static displays of text and graphics. JavaScript gives web pages interactivity and the ability to perform useful work. An important part of JavaScript’s ability to perform useful functions in the browser is its ability to respond to events.

Here is a list of common events that happen in web browsers that JavaScript can respond to.

Event Occurs When . . .
abort The loading of a file is aborted.
blur An element has gone out of focus. In other words, the element is no longer the thing that the user is focusing on.
change An element’s value has changed since losing and regaining focus.
click A mouse has been clicked on an element.
dbclick A mouse has been clicked twice on an element.
error A file failed to load.
focus An element has come into focus. In other words, the element is what the user is currently focusing on.
input The value of an  or 

What are JavaScript reserved words?

JavaScript has some reserved words you should know before you begin coding. The following table contains a list of JavaScript reserved words, which cannot be used as JavaScript variables, functions, methods, loop labels, or object names.

abstract boolean break
byte case catch
char class const
continue debugger default
delete do double
else enum export
extends false final
finally float for
function goto if
implements import in
instanceof int interface
long native new
null package private
protected public return
short static super
switch synchronized this
throw throws transient
true try typeof
var void volatile
while with

About This Article

This article is from the book: 

About the book author:

Chris Minnick is an accomplished author, teacher, and programmer. Minnick authored or co-authored over 20 books, including titles in the For Dummies series. He has developed video courses for top online training platforms and he teaches programming and machine learning to professional developers at some of the largest global companies.

Eva Holland is an experienced web developer, tech trainer, and coauthor of Coding with JavaScript For Dummies. She is a co-founder of WatzThis?, a company focused on training and course development.