GithubHelp home page GithubHelp logo

week-7-advanced-js's Introduction

Week-7-Advanced-JS

Advanced Javascript and DOM Manipulation

In week seven we will discuss the following topics:
  • Event listeners
  • Higher order functions
  • Play sounds on a website
  • Advance Objects (methods, dot notation)
  • Switch statements
  • Keyboard event listeners
  • Callbacks, respond to events
  • Animations

Event listeners

  • Although you can start functions when your page loads, many times you'll want to start functions when a user clicks a link, enters a form, scrolls, moves his or her mouse over an object, or does something else. These actions are called events. You can set specific functions to run when the user performs an event. These functions "listen" for an event and then initiate the function.
  • To understand how event listeners actually works let's check out a simple example:
     //creating a button 
     const btn = document.createElement('button')
     document.body.appendChild(btn)
     btn.innerText = 'this button has event listener'

    // Assigning event handlers to the button
    btn.onclick = secondFunction;

    // Defining custom functions  
    function secondFunction() {
        btn.style.backgroundColor = 'yellow';
        console.log('second function executed');
    }

Higher order functions

  • Higher-order functions are functions that take other functions as arguments or return functions as their results.

  • Taking an other function as an argument is often referred as a callback function, because it is called back by the higher-order function. This is a concept that Javascript uses a lot.

  • For example, the map function on arrays is a higher order function. The map function takes a function as an argument.

  • a simple example:
const double = n => n * 2;

const numbers = [1, 2, 3, 4]

numbers.map(double)

// output: [ 2, 4, 6, 8 ]

Sections of this week


Kind note:

We expect you to always come prepared to the class on Sunday.


week-7-advanced-js's People

Contributors

ekocibar avatar livecodingonline avatar mahmutkaya 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.