-->

  • ES6 Arrow function in Javascript


    ES6 Arrow function in javascript

     

    ES6 Arrow Function


    ES6 Gives us a new syntax for defining functions using a fat arrow. Arrow functions bring a lot of clarity & code reduction.

    ES6 is different version of the ECMAScript specification. Which is the standard that defines the scripting language that javascript is based on.

    ES6 release on 2015 and there are so many features Arrow function, classes, let and const for variables.




    Syntax:


    function greetings(name) {
        return (' Welcome ' + name)
    }
    
    const greetings = (name) => {
        return (`Welcome ${nmae}`)
    }
    
    



    Actually we have used this code in reactjs called as TheArrow.jsx



    Example


    import React from 'react'
    
    function Thearrowfunc() {
    
        
        function greetings(name) {
            return ('welcome ' + name);
         }
         
         const myGreeting = (name, age) =>  {
              console.log(`welcome ${name} ${age}`)
         }
          // without curley braces also we can use arrow function 
        console.log(greetings('atul'));
         console.log(myGreeting('atul', 23));
      return (
        
    <h1>Check console</h1>
    ) } export default Thearrowfunc




    Output




    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.



  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.