Jump to content

() is Null?

babadoctor
Go to solution Solved by squirrl,

yes

i know

i had numbers inside of the ()

but without them it was stated as null right

I think i see what you are trying to say.

 

For example you could have

function takeAFunction(callback, number) { // usually you would have params before the callback though  if (!number) {    return callback && callback('number is null');  }  callback && callback(null, number);}

and then call it like this:

takeAFunction(function(err, res) { console.log(err, res); // will print out "null 1"}, 1);

or like this

takeAFunction(function(err, res) { console.log(err, res); // since number wasn't passed in it will be null and handled as such in "takeAFunction". This will print "number is null null"});

or like this

takeAFunction(1, function() { console.log(err, res); // err and res would be passed in to the anonymous function when called by takeAFunction, but since this particular function does not define them, they will be undefined when logged.});

Basically () is not resolved to null or any other type. It's just formatting. Any parameters which would have been passed into that anonymous function will not be initialised and be undefined. (not null)

() is null in javascript, right?

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

() is null in javascript, right?

 

I thought you had to define it null? 

 

like 

 

String stuff = null;

There are 10 types of people in the world: Those who understand binary, and those who don't.

Just some helpful stuff: You're - You are, Your - Your car, They're - They are, Their - Their car, There - Over there.

 

Folding @ Home Install Guide and Links | My Build

 

Link to comment
Share on other sites

Link to post
Share on other sites

I thought you had to define it null? 

 

like 

 

String stuff = null;

In this string for example:

Color = Data(function() ({ Red: {}, Green: {}, Blue: {}, Yellow: {} })) Point = Data(function() ({ Pt: { x: Number, y: Number, color: Color } }))

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

this is one of many reasons javascript is fucked

what are some of the others lol

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

I'm more used to regular Java, but after looking around, I believe you are correct for javascript. 

 

Javascript and Java are entirely unrelated

Link to comment
Share on other sites

Link to post
Share on other sites

In this string for example:

Color = Data(function() ({ Red: {}, Green: {}, Blue: {}, Yellow: {} })) Point = Data(function() ({ Pt: { x: Number, y: Number, color: Color } }))

That just means you are defining an anonymous function with no parameters.

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

That just means you are defining an anonymous function with no parameters.

yes

i know

i had numbers inside of the ()

but without them it was stated as null right

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

yes

i know

i had numbers inside of the ()

but without them it was stated as null right

I think i see what you are trying to say.

 

For example you could have

function takeAFunction(callback, number) { // usually you would have params before the callback though  if (!number) {    return callback && callback('number is null');  }  callback && callback(null, number);}

and then call it like this:

takeAFunction(function(err, res) { console.log(err, res); // will print out "null 1"}, 1);

or like this

takeAFunction(function(err, res) { console.log(err, res); // since number wasn't passed in it will be null and handled as such in "takeAFunction". This will print "number is null null"});

or like this

takeAFunction(1, function() { console.log(err, res); // err and res would be passed in to the anonymous function when called by takeAFunction, but since this particular function does not define them, they will be undefined when logged.});

Basically () is not resolved to null or any other type. It's just formatting. Any parameters which would have been passed into that anonymous function will not be initialised and be undefined. (not null)

Aragorn (WS): 250D | 6800k | 840 Pro 512GB | Intel 530 480GB  | Asus X99-M WS | 64GB DDR4 | Corsair HX720i | GTX 1070 | Corsair H115i | Philips BDM4350UC 43" 3840x2160 IPS

Gimli (server):  Node 304 | G4560 | ADATA XPG SX8000 128GB | 2x 5TB WD Red | ASROCK H270M-ITX/AC  | 8GB DDR4 | Seasonic 400FL

 Omega (server):                 Fractal Arc Mini R2 | i3 4130 | 500GB Maxtor | 2TB WD Red : Raid 1 | 3TB Seagate Barracuda | 16GB RAM | Seasonic G-450w
Alpha (WS): 900D | 4770k | GTX 780  | 840 Pro 512GB  | GA-Z87X-OC | Corsair RM 850 | 24GB 2400mhz | Samsung S27B970D 2560x1440

                              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×