JavaScript::Code::Variable - A JavaScript Variable Element
#!/usr/bin/perl use strict; use warnings; use JavaScript::Code::Variable; my $string = JavaScript::Code::Variable->new(); $string->name( 'a' ); $string->value( 'This is a Test!' ); print $string->output; my $number = JavaScript::Code::Variable->new()->name('b')->value( 288957 ); print $number->output; my $strnumber = JavaScript::Code::Variable->new( name => 'c' ); $strnumber->value( JavaScript::Code::String->new(value => 288957) ); print $strnumber->output; my $array = JavaScript::Code::Variable->new( { name => 'd' } ); $array->value( [0, 1] ); print $array->output;
A JavaScript Variable Element Class
Example:
var a = 42; // Variable a with a nummeric value of 42 var b = "Test!"; // Variable b with a string value of "Test!"
Gets or sets the name of the variable.
Gets the full name, that is, the name including the any index information
Gets or sets the value of the variable.
If set to undef, the module will check the scope to decide whether or not the variable should be declared.
If set to 0, the module is undeclared und will be declared in its context.
If set to 1, the variable will to be declared in its context.
Returns the javascript-code for that variable.
Two variables are the same if they have the same name.
Two variables are equal if they have the same value.
JavaScript::Code
Sascha Kiefer, esskar@cpan.org
esskar@cpan.org
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install JavaScript::Code, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JavaScript::Code
CPAN shell
perl -MCPAN -e shell install JavaScript::Code
For more information on module installation, please visit the detailed CPAN module installation guide.