Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

callback() function with example

const checkfile = (x,callback)=>{
    if(typeof x !== 'number')
    return callback('not a number'); //(err,{})
    
    callback(false,'yes it is');
}


checkfile(4,(err, data)=>{
    if(err)
    console.log(err);
    else 
    console.log(err);
})
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #function
ADD COMMENT
Topic
Name
5+5 =