After a property has it's value set with either the setExpression() method or the expression() method, you can read this property. s expression or formula using the getExpression() method. This is a useful way to check the current state of a certain element and then if it meets a certain condition, you may want to apply another expression to this property or even remove the expression using the removeExpression() method. An example of this may be an application that has a series of text dynamically sized in relation to the browser width. After clicking a button, you may want to now size it to the browser. s height. Using getExpression(), you can read the current expression of the titles and change them if they are sized in relation to the browser. s width. This will be covered in the next section. The getExpression() method is very simple to use, it accepts only one attribute, and that is a string representing the property which you. d like to read an expression from. An example of this is shown below:
Var theExpression = box1.style.getExpression("left")
In this snippet, the return value of getExpression("left") of the box1 element will return what ever formula was set on this property with setExpression() or expression(). If by any chance the expression has been removed or there was no expression set for this property in the first place, then the return value will display as
undefined. Let's take a
look at the next example, it build upon the setExpression() example, by
now adding a display area showing the expression set for all the boxes on
the screen.