last object returned in chrome dev tools / python / irb /

0

In matlab one could type in the following and get the following reply:

matlab> 1+1
ans = 2 

One could then all the last returned object by simply typing:

matlab> ans 
ans = 2 

That is, the last output seems to be saved in an object named ans. For this rather useful if you are playing around with a little code for some rapid prototyping.

I now wonder if ipython, irb and javascript in the chrome dev tools console have similar functionality and if so, how to call it.

Vincent Warmerdam

Posted 2013-04-11T21:13:03.070

Reputation: 175

Answers

1

In the Chrome Developer Console, whenever you select a value, or an element, you can re-display it by typing $_.

Try this:

  1. Go into Chrome Development Tools on this page
  2. Open the console
  3. Type $("code"), for example - will show all the code elements on the page
  4. Type $_ and you'll see the exact result again

Try your sample: type 1 + 1 -> yields 2. Type $_ -> 2.

Traveling Tech Guy

Posted 2013-04-11T21:13:03.070

Reputation: 8 743