Question

In JavaScript, the following function may return either a Numeric value or a String simply based...

In JavaScript, the following function may return either a Numeric value or a String simply based on the type of data passed to it as parameters.

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

a.) True

b.) False

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hopefully all yours doubt will clear if you have left with any doubt please let me know in comment. I will try my best to resolve that.

Answer :-

Correct option is A which is True.

JavaScript is a dynamic language. So it's variables are dynamic type which means type of variable is decided at run time according to their value.

As shown in below screenshot :-

In first screenshot a and b are integer so we get integer value returned by function. Which is addition of integer a and integer b.

In second screenshot a and b are string so we get string value returned by function. Which is concatenation of string a and string b .

First screenshot :-

Second screenshot :-

Add a comment
Know the answer?
Add Answer to:
In JavaScript, the following function may return either a Numeric value or a String simply based...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT