Geek Culture
Published in

Geek Culture

Introduction to JavaScript

Hello, today I want to chat about some of the basic fundamentals you need to know to get started coding in JavaScript! Before we get started however, it would be beneficial for introductory developers to understand the use of JavaScript and why it is so essential in modern web development.

Overview:

JavaScript is one of the major building blocks of a web page. It allows us to take basic, static content from a website and turn it into dynamic content that enhances both usability and visual appeal. It is what makes a web page “run”.

How is JavaScript “run”?

Most JavaScript is run from files that are given the extension of .js and loaded into the browser via the <script> tag in our HTML.

>> Example file name: main.js

All of the topics I will talk about today are discussed in an excellent, more in depth manner through this website: https://www.javascripttutorial.net/. I highly recommend checking it out, as it also includes things that are not mentioned in this post, but are just as important to know.

In order to better understand the JavaScript language, let us begin by talking about variables.

Variables

We use variables in JavaScript as a way to store the value of something to use later. Below are three ways to declare a variable in JavaScript.

var

This is a generic variable keyword.

let

let will assign a variable just like var, but with slightly different behavior. It mostly differs by creating “block level scope”.

const

This is a variable that cannot be changed. It is short for “constant”.

Primitive Data Types (Strings, Numbers, Booleans)

Basically, “primitive” means that these are some of the most basic data types in JavaScript.

Strings

A string is a block of text. These blocks of text are always defined with quotation marks, whether single or double.

Numbers

Numbers do NOT have quotes around them. They can be negative as well.

Booleans

Booleans are derived from lower-level software development. It powers binary code, which is the very core of computers! Binary code is just a series of both 0’s and 1’s (010101). These numbers represent either true or false. In JavaScript we use these Booleans to mean just that.

Properties and Methods

Data types have built-in functionality known as properties and methods. These extend the functionality so that we can gather information about, or manipulate the types. We will access both properties and methods using the dot notation. First, we provide the name of the variable, a dot, then the name of the property or method.

Properties

With properties, we can access data from our data types. There are many different properties on every data type. Below, we are trying to access the length property of a string. By finding the length, it will tell us how many characters are in the string.

Methods

Methods are different from properties because they are followed with parenthesis. Take a look below at the .toString() method. It will convert a number or Boolean to a string.

Functions

With functions, we can perform a variety of actions in order to return a final product. Fun fact: Methods are a type of function!

Functions always begin with the function keyword. This lets whatever is running your program know what it is and to treat it as such. Then, comes the actual name of the function, followed by open/close parenthesis and brackets. All of our code for the function resides between the brackets.

As seen above, I have declared a function (logsHelloWorld) and then set it up to console.log ‘hello world’. In order to make this function run, I needed to write the function’s name again, followed by parenthesis after the brackets were closed. This is the syntax used to run a function.

As mentioned earlier, this post is more to help introductory developers begin to develop a basic understanding of JavaScript before truly delving into the language. I hope this information is as helpful to you all as it was to me as I was beginning to dip my feet into the world of JavaScript. Happy coding! Below, I will include a few of my favorite JavaScript resources. For visual learners, there are also YouTube videos that teach the fundamentals you should know to get started in JavaScript!

Written Resources:

YouTube:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store