Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

dynamic-variables

Are Variable Operators Possible?

January 3, 2023 by Tarik

Not out of the box. However, it’s easy to build by hand in many languages including JS. var operators = { ‘+’: function(a, b) { return a + b }, ‘<‘: function(a, b) { return a < b }, // … }; var op = ‘+’; alert(operators[op](10, 20)); You can use ascii-based names like plus, … Read more

Categories javascript Tags dynamic-variables, javascript, operator-keyword, operators, variables Leave a comment

Assigning variables with dynamic names in Java

December 30, 2022 by Tarik

This is not how you do things in Java. There are no dynamic variables in Java. Java variables have to be declared in the source code1. Depending on what you are trying to achieve, you should use an array, a List or a Map; e.g. int n[] = new int[3]; for (int i = 0; … Read more

Categories java Tags dynamic-variables, java, variables Leave a comment

Using braces with dynamic variable names in PHP

October 13, 2022 by Tarik

Wrap them in {}: ${“file” . $i} = file($filelist[$i]); Working Example Using ${} is a way to create dynamic variables, simple example: ${‘a’ . ‘b’} = ‘hello there’; echo $ab; // hello there

Categories php Tags dynamic, dynamic-variables, php, variables Leave a comment

Use dynamic variable names in JavaScript

September 21, 2022 by Tarik

Since ECMA-/Javascript is all about Objects and Contexts (which, are also somekind of Object), every variable is stored in a such called Variable- (or in case of a Function, Activation Object). So if you create variables like this: var a = 1, b = 2, c = 3; In the Global scope (= NO function … Read more

Categories javascript Tags dynamic-variables, javascript Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa