Code Monkey home page Code Monkey logo

js-functions's Introduction

Function In JavaScript

The aim of the exercise is to get started with Function

  • Function Decleration
  • Function Expression
    • Arrow Function
  • Function Invocation
  • IIFE

Getting Started

Setup your project by following these instructions:

  • Make your own copy by forking this exercise.
  • Go to the settings of the newly forked repo and add your mentor as a collaborator on the repo.
  • Make a clone of your forked repo.
  • Create a new branch called develop: git checkout -b develop.
  • Work on the exercise on your develop branch.
  • Push commits to develop branch ONLY. Command - git push origin develop.

After you are done.

  • Submit a Pull Request to merge develop branch into the master branch of your repo. Please don't merge your own pull request.
  • Add your mentor as a reviewer on the PR.
  • The assigned mentor will review the exercise and pass feedback.
  • Once the mentor merges the PR to master branch, you are done with this exercise. Yay!

Goals đŸŽ¯

  • Every folder has a .md file and a .js file
  • Go through the instruction form .md file and complete the function in the .js file.

Basic Info 🛠

What is a function

  1. A function is a subprogram designed to perform a particular task.
  2. Functions are executed when they are called. This is known as invoking a function.
  3. Values can be passed into functions and used within the function.
  4. Functions always return a value. In JavaScript, if no return value is specified, the function will return undefined.
  5. Functions are objects.

Defining a function

A Function Declaration defines a named function. To create a function declaration you use the function keyword followed by the name of the function. When using function declarations, the function definition is hoisted, thus allowing the function to be used before it is defined.

function add(a, b){
  return a + b;
}

A Function Expressions defines a named or anonymous function. An anonymous function is a function that has no name. Function Expressions are not hoisted, and therefore cannot be used before they are defined.

let add = function(a, b){
  return a + b;
}

An Arrow Function Expression is a shorter syntax for writing function expressions. Arrow functions do not create their own this value.

let add = (a, b) => {
  return a + b;
}

Function Terms ⚡ī¸

@wesbos

Invoking a Function

Functions execute when the function is called. This process is known as invocation. You can invoke a function by referencing the function name, followed by an open and closed parenthesis: ()

let add = (a, b) => {
  return a + b;
}
add();

Concepts & Resources ℹī¸

  1. Functions
  2. Function expressions and arrows

js-functions's People

Contributors

me-devil avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.