7

How does eval overhere or how does it behave?

 3 years ago
source link: https://www.codesd.com/item/how-does-eval-overhere-or-how-does-it-behave.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How does eval overhere or how does it behave?

advertisements
eval(0+'1'+3) => 11 (???)

When eval(0+'1') is executed =>1. Iam expecting that 0+'1' will give me 1 & 3 will be considered as string & o/p => 13. But, why is that not happening?

whereas

eval(1+'1'+3) => 113


You are creating the string "013", which is evaluated as a JavaScript integer literal. Integer literals starting with 0 are interpreted base 8 (octal), so your number is 8 + 3, which is 11.

Only integer literals starting with a non-zero digit are interpreted base 10.

Tags javascript

Related Articles

Why does `-lt` behave differently for characters and strings?

I recently answered a SO-question about using -lt or -gt with strings. My answer was based on something I've read earlier which said that -lt compares one char from each string at a time until a ASCII-value is not equal to the other. At that point th

Clojure - Why does it behave differently with a list than a vector?

Why does into behave differently when the collection being inserted into is different? For example: user=> (into [] [1 2 3]) [1 2 3] So far, so good. Exactly as I would expect. However: user=> (into () [1 2 3]) (3 2 1) Why does this reverse the argu

How does __eq__ behave in Python and in what order?

Since Python does not provide left/right versions of its comparison operators, how does it decide which function to call? class A(object): def __eq__(self, other): print "A __eq__ called" return self.value == other class B(object): def __eq__(se

How does Static behave here in asp.net?

I have an asp.net application with c# language. I have a common class which maintain the constants and static variables and fields. I also have a login page. If the user logs in successful I set IsLoggedInSuccessfull as a static boolean variable in c

How does locking behave in .net?

abstract class Foo { private List<Object> container; private bool update; Foo Foo() { container = new List<object>(); update = false; } public abstract Bar CreateBar(); public void BeginUpdate() { if (!update) { Thread update_thread = new Thre

Code Ruby that does not work. How comes it? I have included Enumerable, implemented each but reject does not behave as I expect

I wrote this simple class class FibSequence include Enumerable def initialize(num) @sequence = fib(num) end def fib(n) vals = [1, 1] return [1] if n == 1 return vals if n == 2 (n-2).times do vals.push(vals[-1] + vals[-2]) end return vals end def each

perl: how does "$ 1" behave in a loop?

I'm getting some behavior I don't understand in perl: >>> my @words = ('hello', 'there'); >>> $words[0] =~ /(el)/; print $1; el >>> $words[1] =~ /(el)/; print $1; undef but in a loop: >>> my @words = ('hello', 'there');

Does anyone know how this option behaves as Anchor Tag?

This is a very simple question, but I am a bit of a beginner. This image is a combination of a glyphicon from bootstrap and a piece of text, but for some reason whenever I highlight over it, only the icon gets highlighted and not the text. Code Using

Question about the example of Apple's LazyTableImages - Does not behave exactly as the application

I have a UITableView with a list of items, each having it's own image. I thought Apple's LazyTableImages sample project would be perfect to learn from, and use to implement the same kind of process of downloading images asynchronously, after the orig

Task.Delay () does not behave as expected

Task.Delay() not behaving as expected or rather I'm not understanding what it is supposed to do. I'm trying to get my head around Tasks in C# and how to replace Threads in my implementation. What I'm trying to do is something like this: While true pr

Bootstrap modal does not behave as modal

Here's an extremely simple page: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-

The recursive function does not behave properly

We have the following structure in active directory for group memberships: BEL Test Top level - BEL Test Sub level 1 - Bob - BEL Test Sub level 1.1 - Jake - Mike - BEL Test Sub level 2 - BEL Test Sub level 2.1 The desired output: GroupName : BEL Test

The URL does not behave as expected in Zend Framework

When calling the following type of url in a controller's init method I get two different results on two different servers: http://address.com/index/action/?start=2009-04-18&end=2009-04-21 Calling echo $_GET['start']; Gives me 2009-04-18 on one server

& Lt; Select & gt; Width in IE does not behave as in other browsers

I have three select boxes. <div style='float: left; padding-right: 10px;'> <select size="10" name="company_id"> // a lot of options here </select> </div> <div style='float: left; padding-right: 10px;'> <

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK