473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Prototype Assignment functions...

I'm in the process of simplifying my code and I want to find out how feasible it is to do the following...

Example 1:
Expand|Select|Wrap|Line Numbers
  1. Q("a","blah");
  2.  
  3. // or a.Q("blah");
  4. // to assign the value of "blah" to the variable a
  5.  
  6. alert(a); // -----> returns "blah"
Example 2:

Expand|Select|Wrap|Line Numbers
  1. Q("x",123 + 456);
  2.  
  3. // or x.Q(123+456)
  4. // to assign the value of the sum of 123 + 456 to the variable x
  5.  
  6. alert(x); // -----> returns 579
Anybody have any idea how to go about creating a function that could do that?

Please don't question why I want to do this, I want to know if it's possible and how... and please don't provide me with answers like:

Expand|Select|Wrap|Line Numbers
  1. a = "blah";
and

Expand|Select|Wrap|Line Numbers
  1. x = 123 + 456;
Just humor me... this is something I want to try, so I want to know how possible it is to do this sort of thing...

Thanks...

-- Fibonacci Jones
Jan 24 '08 #1
1 1033
acoder
16,027 Expert Mod 8TB
How about:
Expand|Select|Wrap|Line Numbers
  1. function Q(variable, value) {
  2.   window[variable] = value;
  3. }
Jan 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Elf M. Sternberg | last post by:
One of the complaints about prototype.js (google for it if you're not familiar with it) is that it's poorly documented. I have this inkling that the key to understanding prototype.js is in the...
8
by: Robert | last post by:
Hi, I can use "with" like this: function MyObject(message) { this.message = message; } function _MyObject_speak() {
4
by: lkrubner | last post by:
I'm reading an essay, I think one of Crockford's, and it has this example in it: function Demo() { } Demo.prototype = new Ancestor(); Demo.prototype.foo = function () { } ; Does Ancestor now...
21
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
12
by: petermichaux | last post by:
Hi, I've been reading the recent posts and older archives of comp.lang.javascript and am surprised by the sentiments expressed about the prototype.js library for a few reasons: 1) The library...
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
6
by: mmcloughlin | last post by:
I'm learning about objects and am trying to figure out how basic inheritance works. I've got into the habit of explicitly setting the prototype object with an object literal as it seems to make the...
5
by: Daz | last post by:
Hi everyone. My query is very straight forward (I think). What's the difference between someFunc.blah = function(){ ; } and
3
by: jacobstr | last post by:
I've noticed Object.extend used in a few different ways and I'm having trouble distinguishing why certain usages apply to a given situation. On line 804 Ajax.Base is defined as follows: ...
3
by: Robert | last post by:
Hi, I thought I pretty much understood the whole prototype chain stuff, but now I stumbled upon a difference between IE and Firefox, that is totally confusing me. An example.......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.