Salesforce Javascript 1 Exam Study Guide

My Javascript Background

My Javascript journey started during the “first” browser wars between Internet Explorer 6 and Netscape which IE6 eventually won but then lost to Chrome and Firefox. This was before JQuery and Node.js. Manipulating a web site’s DOM was my primary use case. My early experience with Javascript was ok but after inheriting a particular bad and large codebase, my taste for it was not good and I tried avoiding it as much as possible. However, things have gotten better the last few years and I’m liking it again.

I’m pretty familiar with the syntax but don’t use the prototypal inheritance much and have to refresh myself on the newer features. To study, I’m going to read some Javascript books on safaribooksonline, which is an awesome technology learning platform, and review the Salesforce Certified JavaScript Developer I Exam Guide resources.

Results

On December 24, 2020, I passed the exam in 60 minutes and earned the credential since the LWC super badge was done already. Overall, I thought the exam was easy after studying. A lot of it was given this code, what will the output be or what needs to be changed to produce this output. The super badge took about 30 hours. Studying for the exam was another 30 hours of reading a few books, installing node and using it with VS code, and watching some videos.

Definitely study the browser APIs since there were a few questions on them. Study APIs like storage, history, geolocation, events, cookies, etc.

Node had fairly specific questions too. Learn how to start it, the modules available, what language features are supported, how versions are supported, and how to create modules in it.

Also, learn how to implement object inheritance using prototypes in ecmascript 5 and using classes in ecmascript 6.

I thought there would be questions around the Reflect and Proxy objects but there weren’t. Perhaps that’ll be on the Javascript Developer 2 certification.

Below is my study guide that I hope helps. It doesn’t cover everything but some fundamentals are and additional resources are provided. Good luck!!

About the Certification

The exam consists of two parts, a multiple choice exam and the Lightning Web Components Super Badge. They can be completed in any order. However, I recommend completing the LWC Super Badge first because it lets you get more hands-on with Javascript via LWCs. It took me approximately 30 hours to complete.

About the Exam

  • Content: 60 multiple-choice/multiple-select questions
  • Time allotted to complete the exam: 105 minutes
  • Passing score: 65%
  • Registration fee: USD 200, plus applicable taxes as required per local law
    Reschedule fee: USD 100, plus applicable taxes as required per local law
  • Delivery options: Proctored exam delivered onsite at a testing center. Click here for information on scheduling an exam.
  • References: No hard-copy or online materials may be referenced during the exam.
  • Prerequisite: None

Recommended Training & References

Source: Javascript Developer 1 Exam Guide

  • Data Types & Operators
  • Scope
  • Type conversion (implicit vs. explicit)
  • Strings
  • Functions (plus higher order functions)
  • Data Structures: Objects & Arrays
  • Document Object Model
  • Classes
  • Modules
  • Events
  • Error Handling
  • Debugging
  • Testing (Platform agnostic)
  • Asynchronous Programming
  • Server-side JavaScript

Exam Outline

Source: Javascript Developer 1 Exam Guide

Variables, Types, and Collections: 23%

  • Given a scenario, write code to create variables and initialize them correctly.
  • Given a business requirement, utilize strings, numbers, and dates effectively.
  • Given a scenario or example, demonstrate awareness of type coercion and its effects.
  • Given a specific scenario, distinguish truthy or falsey evaluations
  • Given a list of data, demonstrate data manipulation with arrays.
  • Given a JSON response, demonstrate how to operate the JSON object.
  • Key Topics
    • Variables
    • Strings, Numbers, and Dates
    • Type Coercion
    • Truthy or falsy evaluations
    • Data manipulation with arrays
    • JSON objects
    • Source

Objects, Functions, and Classes: 25%

  • Given a business requirement, locate the best function implementation.
  • Given a business requirement, apply fundamentals of object implementation to solve the business requirement.
  • Given a business requirement, apply fundamentals of class implementation to solve the business requirement.
  • Given a JavaScript module, give examples of how to use the module.
  • Given a JavaScript decorator, give examples of how to use the decorator.
  • Given a block of code, analyze the variable scope and the execution flow.
  • Key Topics
    • Best Function Implementation
    • Fundamentals of object implementation
    • Fundamentals of class implementation
    • How to use the modules
    • Variable scope and the execution flow
    • Source

Browser and Events: 17%

  • Given a business requirement, utilize Events, event handlers and propagation.
  • Given a business requirement, evaluate and manipulate the DOM.
  • Given a scenario, utilize the Browser Dev Tools to investigate code behavior. 
  • Given a scenario and requirements, utilize browser specific APIs.
  • Key Topics
    • Event Handlers
    • DOM Manipulation
    • Event objects
    • Default actions
    • Pointer events
    • Timers
    • Debouncing
    • Source

Debugging and Error Handling: 7%

  • Given a scenario, handle errors properly.
  • Given code to be debugged, use the console and breakpoints.
  • Key Topics
    • Exceptions
    • Selective Catching
    • Assertions
    • Breakpoints
    • Source

Asynchronous Programming: 13%

  • Given a scenario, apply asynchronous programming concepts.
  • Given a scenario, use event loop and event monitor or determine loop outcomes.
  • Key Topics
    • Callbacks
    • Promises
    • Failures
    • Asynchronous Functions
    • Source

Server Side JavaScript: 8%

  • Given a scenario and requirements, infer which Node.js implementation is a good solution.
  • Given a scenario and requirements, infer which Node.js CLI command is a good solution.
  • Know the core Node.js modules and given requirements, infer which Node.js library/framework is a good solution.
  • Given a scenario and requirements, distinguish which Node.Js Package Management solution is the most fitting.
  • Key Topics
    • Node.js fundamentals
    • Package files
    • File System and HTTP modules
    • Streams
    • Source

Testing: 7%

With a block of code and the associated Unit Test, determine where the test is ineffective and modify it to make it more effective.

Key Topics

  • Test Types
  • Running Tests
  • Testing tools
  • Source

Variables

Variables can hold numbers, strings, booleans, as primitives. They can also hold arrays, objects, and functions. They’re declared using var or let.

Variable names can start with a letter, underscore “_”, or a dollar sign “$” and can be followed by as many letters, numbers, underscores, and dollar signs as needed. Variable names can’t use reserved keywords, which are reserved for use in the programming language such as for, if, new, etc.

Variable names are also case-sensitive so “foo” and “FoO” are two different variables.

KeywordScopeEditable
varfunctionyes
letblockyes
constblockno

Loops

Loops let someone perform the same instructions on multiple items. There are different types of loops.

While Loops

While loops keep executing as long as its conditional is true.

while (boolean_expression_is_true) {

// Do these actions

}

Branching

If Statements

if statements evaluate a conditional and execute those actions if true and may execute other actions in an optional else. It supports if then, if then else, and if then else if else if else styles.

Arrays

Javascript has arrays like other languages and are zero-based indexed. Declare an array like this:

var arr = []; // empty array

var arr = [100]; // Single element

console.log(‘arr first element: ‘ + arr[0]); // 100

arr[0] = 200; // Updates first element to 200

Array elements don’t have to be the same type but typically are.

Accessing and out of bounds array doesn’t throw an error and undefined is returned.

Arrays have a “length” property, which represents the number of items in the array.

Objects

Objects are a collection of properties. Use the dot, “.” operator to access an object’s properties.

After an object is created, a property can be easily added or removed from it. To add, obj.newProp = someValue;

To delete a property:

delete obj.newProp; // will be undefined if used after this since the property is deleted

Creating an empty object: var obj = {};

Object Literal

Create an object by writing it out like this:

var objectLiteral = {

prop1: “Property 1”,

prop2: “Propert 2”,

prop3: true

func1: function() { }

function2() { }

}

Object Constructors

An object constructor is a special type of function declaration that is used with the new keyword to instantiate an object.

function Cat(name, weight, breed) {

this.name = name;

this.weight = weight;

this.breed = breed;

}

var myPet = new Cat(‘Luke’, 10, ‘Tiger’);

var myPet2 = new Cat(‘Jose’, 20, ‘Lion’);

Use for in loop to iterator over object properties

for (let propertyName in obj) {

console.log(propertyName + ‘: ‘ + obj[propertyName]);

}

instanceOf Operator

The instanceOf operator returns true if an object was created by the specified constructor. For example:

if (myPet instanceOf Cat) { }

Prototype

Javascript doesn’t use classes. Objects inherit behavior from other objects which is called prototypal inheritance.

Constructors always have a prototype property.

Any method or variables added to the prototype, even after objects are already instantiated, will immediately inherit them.

One can override inherited properties and method by updating the prototype’s properties and methods. For example, one can override the toString function which is inherited from the Object. Object is the root object that all other object derive from, similar to Java.

Object Methods To Not Override

  • isPrototypeOf – determines if this object is the prototype of another object.
  • hasOwnProperty – determines if a property is on this object or inherited from another one. True if on this object.
  • constructor – reference to the constructor function connected to the prototype.
  • propertyIsEnumerable – sees if a property is accessible by iterating through all an object’s properties. I.e. for (let prop in obj) { }.

Object Methods To Override

  • toString – returns a string representing this object.
  • toLocaleString – returns a string representing an object specific to a country and/or language.

Extending Built-In Objects

One can add properties and methods to some built-in objects like Object or String but others like Array aren’t designed to be extended.

Everything is an Object

Everything in Javascript is an object including functions and primitives. Boolean, strings, and numbers are converted to objects as needed automatically.

Functions

Primitives are pass-by-value aka are copied into function parameters.

Objects are pass-by-reference aka their pointers are passed in so any changes made within the function are visible to its invoker.

// function declaration

function foo(param1) {

// do work here

}

foo(‘bar’); // function invocations

// Function Expression is a function assigned to a variable

var foo = function(bar) {

// do some work

}

foo(‘bar’); // Also invokes the function expression stored in foo

A function declaration creates a function and is created before the rest of the code runs. A function expression is created as the code runs at runtime.

Functions can be assigned to variables, passed to other functions, and be returned from functions. This makes them first-class citizens.

Scoping Rules

Javascript functions are evaluated in the same scoping environment in which they were defined. To determine where a variable is coming from within a function, search the enclosing functions from inner most nested to outer. If it’s not found in the function, check the global scope. If not found there, it’s undefined.

Types

There are two groups of types in Javascript, primitives and objects. Any value that’s not a primitive is an object.

Primitives

  • booleans
  • strings
  • numbers
  • undefined
  • null
  • Symbol

Nan – Not A Number

Nan or “Not a Number” represent numeric results that can’t be represented such as 0 / 0.

typeof NaN // outputs “number”

NaN != NaN – It doesn’t equal itself. To check for it, use isNaN function.

Equality == Comparison Rules

These comparison rules were taken from the Head First Javascript Programming book by Eric T. Freeman and Elisabeth Robson.

Number == String

When a number is compared to a String, the string is converted to a number and then the numbers are compared for equality. An empty string is converted to 0.

“” => 0 in a type conversion

Boolean == Other Type

Boolean is converted to a number and then compare. true converts to 1 and false converts to 0.

1 == true

0 == false

Sometimes this requires more than one type conversion.

Null == undefined

null == undefined // true

NaN != NaN

NaN == NaN // false

NaN is not a number represents a number that can’t be represented. It’s type is “number” and doesn’t equal anything else including itself.

Object Equality with ==

Objects are equal if and only if they are the same object.

const objA = {};
const objB = {};

console.log(`objA == objB: ${objA == objB}`); // false

const objC = objA;

console.log(`objA == objC: ${objA == objC}`); // true

Other == Examples

----- String to number Comparisons -------
100 == "tree" becomes
100 == NaN // false

100 == "100" becomes
100 == 100 // true

"" == 1 becomes
0 == 1 // false

----- Boolean with other types Comparisons -----
true == "on" becomes
1 == "on" becomes
1 == NaN // false

true == 1 becomes
1 == 1 // true

true == 10 becomes
1 == 10 // false

"0" == false becomes
"0" == 0 becomes
0 == 0 // true

Strict Equality === Comparison Rule

Two values are equal if and only if they have the same type and the same value.

Truthy Vs Falsey Values

Some values aren’t true or false but Javascript still treats them as such in conditionals. Easier to concentrate on the falsey values and then everything else is considered “truthy”.

Falsey Values

  • undefined
  • null
  • 0
  • “” – empty string
  • NaN – Not a Number
  • false

Everything else is considered true.

+ Operator

The + operator is used to add two numbers together or to concatenate two strings together. If ones tries to add a string and a number, Javascript converts the number to a string and concatenates them.

7 + "3" is "73"
"3" + 7 is "37"

3 + 5 + " animals" is "8 animals" because 3 + 5 is evaluated first

Other Math Operators

Other Math operators like -, *, and / are treated as math operations on numbers. When a string is encountered, Javascript tries to convert it to a number. Examples:

1 * “2” is 2

“4” / 2 is 2

“15” – 3 is 12

Classes

The class keyword in Javascript is syntactic sugar to address the complexities of prototype inheritance. The engine is still using Object.create under the hood. Source

Resources

Leave a Reply

Your email address will not be published. Required fields are marked *